<?php

namespace App\Providers;

use Illuminate\Contracts\View\View;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\DB;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //分配商品标签分类
        $tag = DB::table('tag')->get();
        //广告图片展示
        $ad = DB::table('img')->where('img.status','=',1)
            ->leftJoin('goods','img.goods_id','=','goods.goods_id')
            ->get();
        //标签下热门商品的展示
        $goods = DB::table('goods')
            ->where('hot','=',1)
            ->leftJoin('img','goods.goods_id','=','img.goods_id')
            ->get();

        //分配session信息到主页模板
        //$user_info= session('sign_user_info');
       view()->share('tag',$tag);
       view()->share('ad',$ad);
       view()->share('goods',$goods);
       //view()->share('user_info',$user_info);
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
